Title: Adding triggers in WeeChat to help parse server notices
Date: 2020-05-25 16:30
Category: Weechat
Tags: CLI, weechat, bitlbee, tmux


###Intro
It's been a while since I've posted, but that's the way of blogs is it not?
This should be a short one.

Anyway, why am I here today?
Because asshats live on the internet :(

Despite having things in place in [InspIRCd] like [dnsbl] and various other configurations to reduce trolls and botnets, people still find ways to ruin things for everyone else.

Some script kiddy decided to use a number of connections from various asian hosts -- many of which were yet to be included on the ip blacklists -- and started spamming.



###On to the point
All of this led me to wanting to make the connection/quitting IRC server notices a bit easier to parse.
Bringing us to [WeeChat]'s [triggers] and some simple RegEx [again].


####The Triggers
Here I came up with four triggers to:

* Highlight the connect msgs and the nick
* Highlight if the connect class is "Main" (Inspircd)
    * Makes it easy to see that a user is on an external connection
* Highlight the quit msgs and the nick
* Highlight xline msgs
    * Makes it quick to see when dnsbl catches connections
* **UPDATED:** Highlight announcement/oper msgs
* **UPDATED:** Added CHANCREATE higlights

And the triggers:

    :::bash
    /trigger addreplace ircd_notice_con modifier weechat_print "${tg_tags} =~ irc_notice" "/(CONNECT:)(.*: )([^ !]+)(!.*)/${color:02}${re:1}${color:reset}${re:2}${color:14}${re:3}${color:reset}${re:4}/" ""
    /trigger addreplace ircd_notice_con_main modifier weechat_print "${tg_tags} =~ irc_notice" "/(CONNECT:)(.*class )(main)(.*)/${re:1}${re:2}${color:01}${re:3}${color:reset}${re:4}/" ""
    /trigger addreplace ircd_notice_quit modifier weechat_print "${tg_tags} =~ irc_notice" "/(QUIT:)(.*: )([^ !]+)(!.*)/${color:03}${re:1}${color:reset}${re:2}${color:06}${re:3}${color:reset}${re:4}/" ""
    /trigger addreplace ircd_notice_xline modifier weechat_print "${tg_tags} =~ irc_notice" "/(XLINE:)(.*)/${color:01}${re:1}${color:reset}${re:2}/" ""
    /trigger addreplace ircd_notice_announce modifier weechat_print "${tg_tags} =~ irc_notice" "/(ANNOUNCEMENT:)(.*)/${color:05}${re:1}${color:reset}${re:2}/" ""
    /trigger addreplace ircd_notice_oper modifier weechat_print "${tg_tags} =~ irc_notice" "/(OPER:)(.*)/${color:05}${re:1}${color:reset}${re:2}/" ""
    /trigger addreplace ircd_notice_chancreate modifier weechat_print "${tg_tags} =~ irc_notice" "/(CHANCREATE:)(.*Channel )(.*)( created by )(.*)(!.*@.*)/${color:11}${re:1}${color:reset}${re:2}${color:5}${re:3}${color:reset}${re:4}${color:014}${re:5}${color:reset}${re:6}/" ""


###The Pudding
For your convenience, here is a screenshot. <sup>(With redactions)</sup>
![weechat server notice trigger]({static}/pics/weechat_server_notice_trigger.png)


###Links
[InspIRCd]  
[dnsbl]  
[WeeChat]  
[triggers]  
[again]  


[InspIRCd]: https://www.inspircd.org/
[dnsbl]: https://docs.inspircd.org/3/modules/dnsbl/
[WeeChat]: https://weechat.org/
[triggers]: https://weechat.org/files/doc/stable/weechat_user.en.html#trigger_plugin
[again]: {filename}011-weechat_bitlbee_facebook_emotes.md
